package com.elf.bluetoothtest.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;


/**
 * fragment基类
 */
public abstract class AbsFrameLayout extends FrameLayout {

    public AbsFrameLayout(Context context) {
        this(context, null);
    }

    public AbsFrameLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

    /**
     * 初始化布局
     */
    private void init(AttributeSet attrs) {
        initView(attrs);
    }

    /**
     * 初始化view
     */
    protected abstract void initView(AttributeSet attrs);

    protected void showToast(String msg) {
        Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
    }

    protected void showDialog(String msg) {
        new AlertDialog.Builder(getContext()).setMessage(msg).show();
    }

}
